﻿<!--
 Copyright © 2012-2013 Nokia Corporation. All rights reserved.
 Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. 
 Other product and company names mentioned herein may be trademarks
 or trade names of their respective owners. 
 See LICENSE.TXT for license information.
-->
    
<phone:PhoneApplicationPage
    x:Class="NFCTalk.TalkPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:NFCTalk"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    d:DataContext="{d:DesignData SampleData/MessagesSampleData.xaml}"
    shell:SystemTray.IsVisible="True">

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="NFC TALK" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="{Binding Communication.PeerName}" Style="{StaticResource PhoneTextTitle1Style}" Margin="9,-7,0,0"/>
        </StackPanel>
        
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <ListBox x:Name="talkListBox" ItemsSource="{Binding Messages}" Margin="12,0,12,0">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <local:TalkTemplateSelector Content="{Binding}">
                            <local:TalkTemplateSelector.OutBoundTemplate>
                                <DataTemplate>
                                    <StackPanel Width="436">
                                        <StackPanel Background="#3366FF" MinWidth="160" MaxWidth="420" Margin="0,0,0,18" HorizontalAlignment="Left">
                                            <TextBlock Text="{Binding Name}" Margin="12,12,12,0" Style="{StaticResource PhoneTextSmallStyle}" Foreground="White"/>
                                            <TextBlock Text="{Binding Text}" Margin="12,6,12,12" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Foreground="White"/>
                                        </StackPanel>
                                    </StackPanel>
                                </DataTemplate>
                            </local:TalkTemplateSelector.OutBoundTemplate>
                            <local:TalkTemplateSelector.InBoundTemplate>
                                <DataTemplate>
                                    <StackPanel Width="436">
                                        <StackPanel Background="#0033CC" MinWidth="160" MaxWidth="420" Margin="0,0,0,18" HorizontalAlignment="Right">
                                            <TextBlock Text="{Binding Name}" Margin="12,12,12,0" Style="{StaticResource PhoneTextSmallStyle}" HorizontalAlignment="Right" Foreground="White"/>
                                            <TextBlock Text="{Binding Text}" Margin="12,6,12,12" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" HorizontalAlignment="Right" Foreground="White"/>
                                        </StackPanel>
                                    </StackPanel>
                                </DataTemplate>
                            </local:TalkTemplateSelector.InBoundTemplate>
                            <local:TalkTemplateSelector.OutBoundArchivedTemplate>
                                <DataTemplate>
                                    <StackPanel Width="436">
                                        <StackPanel Background="#828282" MinWidth="160" MaxWidth="420" Margin="0,0,0,18" HorizontalAlignment="Left">
                                            <TextBlock Text="{Binding Name}" Margin="12,12,12,0" Style="{StaticResource PhoneTextSmallStyle}" Foreground="White"/>
                                            <TextBlock Text="{Binding Text}" Margin="12,6,12,12" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" Foreground="White"/>
                                        </StackPanel>
                                    </StackPanel>
                                </DataTemplate>
                            </local:TalkTemplateSelector.OutBoundArchivedTemplate>
                            <local:TalkTemplateSelector.InBoundArchivedTemplate>
                                <DataTemplate>
                                    <StackPanel Width="436">
                                        <StackPanel Background="#474747" MinWidth="160" MaxWidth="420" Margin="0,0,0,18" HorizontalAlignment="Right">
                                            <TextBlock Text="{Binding Name}" Margin="12,12,12,0" Style="{StaticResource PhoneTextSmallStyle}" HorizontalAlignment="Right" Foreground="White"/>
                                            <TextBlock Text="{Binding Text}" Margin="12,6,12,12" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" HorizontalAlignment="Right" Foreground="White"/>
                                        </StackPanel>
                                    </StackPanel>
                                </DataTemplate>
                            </local:TalkTemplateSelector.InBoundArchivedTemplate>
                        </local:TalkTemplateSelector>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            
            <StackPanel Grid.Row="1" Orientation="Horizontal" >
                <TextBox x:Name="messageInput" Width="357" InputScope="Chat" TextChanged="messageInput_TextChanged"/>
                <Button x:Name="sendButton" Width="100" Content="say" Click="sendButton_Click"/>
            </StackPanel>
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>
